package com.guli.mall.member.controller;

import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;

import com.guli.mall.member.entity.MemberLoginLogEntity;
import com.guli.mall.member.service.MemberLoginLogService;
import com.guli.common.utils.PageUtils;
import com.guli.common.utils.R;


/**
 * 会员登录记录
 *
 * @author 罗俊华
 * @email 1007052116@qq.com
 * @date 2020-10-18 18:44:16
 */
@RestController
@RequestMapping("member/memberloginlog")
public class MemberLoginLogController {
    @Autowired
    private MemberLoginLogService memberLoginLogService;


    @GetMapping("/list/{currentPage}/{size}")
    @ApiOperation("根据当前页和每页显示的记录数来获取memberLoginLog分页列表")
    public R list(@PathVariable("currentPage") Integer currentPage, @PathVariable("size") Integer size,@RequestParam Map<String, Object> params) {
        PageUtils<MemberLoginLogEntity> page = memberLoginLogService.queryPage(currentPage,size,params);

        return R.ok().put("page", page);
    }



    @GetMapping("/info/{id}")
    @ApiOperation("根据id获取MemberLoginLog")
    public R info(@PathVariable("id") Long id) {
            MemberLoginLogEntity memberLoginLog = memberLoginLogService.getById(id);

        return R.ok().put("memberLoginLog", memberLoginLog);
    }

    @PostMapping("/save")
    @ApiOperation("插入MemberLoginLog")
    public R save(@RequestBody MemberLoginLogEntity memberLoginLog) {
            memberLoginLogService.save(memberLoginLog);

        return R.ok();
    }

    @PostMapping("/update")
    @ApiOperation("根据id更新MemberLoginLog")
    public R update(@RequestBody MemberLoginLogEntity memberLoginLog) {
            memberLoginLogService.updateById(memberLoginLog);

        return R.ok();
    }

    @PutMapping("/deleteBatch")
    @ApiOperation("根据id批量删除MemberLoginLog")
    public R delete(@RequestBody Long[] ids) {
            memberLoginLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
